from driver import GPIO
import utime as time
import uos

print("hello world")

list_json = uos.listdir("/haas/")
print(list_json)

list_json2 = uos.listdir("/flash/")
print(list_json2)

# 实例化一个gpio对象
led1 = GPIO()
led2 = GPIO()
led1.open("system_led")
led2.open("net_led")
while True:
    led1.write(1)
    led2.write(0)
    print("led1")
    time.sleep(1)
    led1.write(0)
    led2.write(1)
    print("led2")
    time.sleep(1)
    # list_json = uos.listdir("/luadb/")
    # print("/luadb:{}".format(list_json))

    try:
        init_config_file = "/luadb/config.json"
        with open(init_config_file, "r") as f:
            config_json = json.load(f)
            print("luadb/config.json:{}".format(config_json))
    except:
        print("luadb/config.json not found")
        pass
    
    time.sleep(1)
    try:
        haas_config_file = "/haas/config.json"
        with open(haas_config_file, "r") as f:
            config_json2 = json.load(f)
            print("haas/config.json:{}".format(config_json2))
    except:
        print("haas/config.json not found")
        pass

    time.sleep(1)
    # list_json = uos.listdir("/haas/")
    # print("/haas:{}".format(list_json))

    # list_json2 = uos.listdir("/flash/")
    # print("/flash:{}".format(list_json2))
